<extend name="_layout/main"/>
<block name="head">
    <style>
        .settlement {
            bottom: 0;
        }

        .warptwo {
            padding-bottom: 1.8rem;
        }

        .settlement a {
            width: 100%;
        }

        .confirm .lie .right .jifen {
            font-size: 0.3rem;
        }
    </style>
</block>
<block name="top">
    <header class="mui-bar mui-bar-nav" id="header">
        <a class="btn" href="javascript:history.go(-1)">
            <i class="iconfont icon-fanhui"></i>
        </a>
        <div class="top-sch-box top-sch-boxtwo flex-col">
            确认订单
        </div>
    </header>
</block>
<block name="content">
    <input type="hidden" name="id" value="{$order.id}"/>
    <div class="warp warptwo clearfloat">
        <div class="confirm clearfloat">
            <div class="gmshu clearfloat box-s">
                <div class="middle clearfloat fl">
                    <p class="fl">
                        订单号：{$order.order_id}
                    </p>
                    <p class="fl">
                        合计： 现金{$order.order_balance} + 积分{$order.order_integral} + 券{$order.order_coupon}
                    </p>
                </div>
            </div>
            <volist name="goods" id="item">
                <div class="lie clearfloat">
                    <a href="{:U('Goods/detail', ['id'=>$item['goods_id']])}">
                        <div class="tu clearfloat fl">
                            <img src="{$item.goods_thumb}"/>
                        </div>
                    </a>
                    <div class="right clearfloat fl">
                        <a href="detail.html">
                            <p class="tit over">{$item.goods_name}</p>
                        </a>
                        <div class="xia clearfloat">
                            <a href="detail.html">
                                <p class="jifen fl over">
                                    <gt name="item.goods_price_balance" value="0">
                                        {$item.goods_price_balance}现金
                                    </gt>
                                    <if condition="$item['goods_price_balance'] gt 0 && $item['goods_price_integral'] gt 0">
                                        +
                                    </if>
                                    <gt name="item.goods_price_integral" value="0">
                                        {$item.goods_price_integral}积分
                                    </gt>
                                    <if condition="$item['goods_price_coupon'] gt 0 && $item['goods_price_integral'] gt 0">
                                        +
                                    </if>
                                    <gt name="item.goods_price_coupon" value="0">
                                        {$item.goods_price_coupon}券
                                    </gt>
                                </p>
                            </a>
                            <span class="fr db">×{$item.goods_number}</span>
                        </div>
                    </div>
                </div>
            </volist>

            <notempty name="address">
                <div class="add clearfloat box-s">
                    <volist name="address" id="val">
                        <a href="{:U('Address/index')}">
                            <input type="hidden" name="address" id="address" value="{$val.id}"/>
                            <div class="left clearfloat fl">
                                <i class="iconfont icon-dizhi1"></i>
                            </div>
                            <div class="middle clearfloat fl">
                                <p class="tit">
                                    收货人：{$val.name}&nbsp;&nbsp;&nbsp;&nbsp;{$val.mobile}
                                </p>
                                <p class="fu-tit over2">
                                    收货地址：{$val.province} {$val.city} {$val.area} {$val.address}
                                </p>
                            </div>
                            <div class="left clearfloat fr">
                                <i class="iconfont icon-jiantou1"></i>
                            </div>
                        </a>
                    </volist>

                </div>
                <else/>
                <div class="gmshu gmshutwo clearfloat box-s fl">
                    <div class="gcontent clearfloat">
                        <p class="fl">暂无收货地址</p>
                        <a href="{:U('Address/add')}">
                            <div class="you clearfloat fr">
                                <span>立即添加</span>
                                <i class="iconfont icon-jiantou1"></i>
                            </div>
                        </a>
                    </div>
                </div>
            </notempty>

            <div class="gmshu gmshutwo clearfloat box-s fl">
                <div class="gcontent clearfloat">
                    <p class="fl">配送方式</p>
                    <div class="you clearfloat fr">
                        <span>快递 免邮</span>
                        <i class="iconfont icon-jiantou1"></i>
                    </div>
                </div>
            </div>
            <div class="gmshu gmshutwo clearfloat box-s fl">
                <div class="gcontent clearfloat">
                    <p class="fl">发票信息</p>
                    <div class="you clearfloat fr">
                        <div class="xuan clearfloat">
                            <div class="radiotwo">
                                <label>
                                    <input type="radio" name="invoice" value="1"/>
                                    <div class="option"></div>
                                    <span class="opt-text">需要发票</span>
                                </label>
                            </div>
                        </div>
                        <div class="xuan clearfloat">
                            <div class="radiotwo">
                                <label>
                                    <input type="radio" name="invoice" value="0" checked/>
                                    <div class="option"></div>
                                    <span class="opt-text">不需要发票</span>
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="gmshu gmshuthree clearfloat box-s fl">
                <div class="gcontent clearfloat">
                    <p class="fl">买家留言</p>
                    <div class="you clearfloat fl">
                        <input type="text" name="message" id="message" value="" class="text" placeholder="给商家留言"/>
                    </div>
                </div>
            </div>

            <div class="integral clearfloat fl box-s">
                <p class="fl">账户</p>
                <div class="zuo clearfloat fr">
                    现金{$wealth.balance}&nbsp;&nbsp;&nbsp; 积分{$wealth.integral}&nbsp;&nbsp;&nbsp; 券{$wealth.coupon}
                </div>
            </div>

        </div>
    </div>
    <div class="settlement clearfloat">
        <if condition="($order['order_balance'] gt $wealth['balance']) || ($order.order_integral gt $wealth.integral) || ($order.order_coupon gt $wealth.coupon)">
            <a href="javascript:;" class="fl db">
                账户余额不足
            </a>
            <else/>
            <a href="javascript:;" class="fl db" id="btn-confirm">
                立即支付
            </a>
        </if>
    </div>
</block>
<block name="scripts">
    <script>
        $(document).on('click', '#btn-confirm', function (e) {
            var id = $('input[name="id"]').val();
            var address = $('#address').val();
            var invoice = $('input[name="invoice"]:checked').val();
            var message = $('#message').val();
            if (!id || isNaN(id)) {
                mui.alert('参数错误');
                return;
            }
            if (!address || isNaN(address)) {
                mui.alert('请选择收货地址');
                return false;
            }
            var data = {};
            data.id = id;
            data.address = address;
            data.invoice = invoice;
            data.message = message;
            mui.confirm('确认支付该订单吗？', '友情提示', ['确定', '取消'], function (obj) {
                if (obj.index == 0) {
                    $.post("{:U('GoodsOrder/pay')}", data, function (xdata) {
                        if (xdata.status == 'success') {
                            mui.alert(xdata.message, '支付成功', function () {
                                document.location.href = xdata.data.url;
                            })
                        } else {
                            mui.alert(xdata.message);
                        }
                    }, 'json')
                }
            })
        })
    </script>
</block>